import {
  PostRes,
  DisableRes,
  RefTonOrderStamp,
  putTonOrderStampDto,
  TonOrderStampGateway,
  deleteTonOrderStampDto,
  TonOrderStampInterfaceWithGrant,
} from "qqlx-core";

import { ViewBase, ViewBaseAction } from "../view-base";
import { RefTonOrderStampSchema } from "@/river/ton-order";

export class ViewTonOrderStamp extends ViewBase<RefTonOrderStamp> implements ViewBaseAction<RefTonOrderStamp>, TonOrderStampInterfaceWithGrant<{}> {
  private static instance: ViewTonOrderStamp;
  static getInstance(options?: { isSingleton?: boolean }) {
    if (options?.isSingleton === false) {
      return new ViewTonOrderStamp();
    }

    if (!this.instance) this.instance = new ViewTonOrderStamp();
    return this.instance;
  }

  private constructor() {
    super();
    this.initial();
    this.insertDefaultCondition();
  }

  getSchema(): RefTonOrderStamp {
    return new RefTonOrderStampSchema();
  }

  async put(dto: putTonOrderStampDto) {
    this.pending();
    return this.$request.put<putTonOrderStampDto, PostRes<RefTonOrderStamp>>(TonOrderStampGateway.path, dto);
  }

  async delete(dto: deleteTonOrderStampDto) {
    this.pending();
    return this.$request.delete<deleteTonOrderStampDto, DisableRes>(TonOrderStampGateway.path, dto);
  }
}
